package heap

import (
	"database/sql"
	"game/game-db/mysql/dao"
	"game/readygo/quickstart/repository"
)

type EntityService[T repository.ICacheRepositoryEntity] struct {
	IRepository repository.IRepository[T]
}

func (t *EntityService[T]) InitRepository(db *sql.DB, entityTemplate T) {
	iDao := dao.NewDefaultBaseDao(db, entityTemplate)
	t.IRepository = repository.NewCacheRepository(iDao, entityTemplate)
}

func (t *EntityService[T]) Insert(entity T) {
	t.IRepository.Insert(entity)
}

func (t *EntityService[T]) Update(entity T) {
	t.IRepository.Update(entity)
}
